]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Throw GObject.NotImplementedError when requiring overriding
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 21 May 2019 20:28:07 +0000 (15:28 -0500)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 21 May 2019 20:43:21 +0000 (15:43 -0500)
Since version 1.50.0, gjs defines GObject.NotImplementedError for throwing
errors when a "virtual" method that requires a subclass implementation is not
defined.

So use this instead of a generic JS Error in such cases.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/549

js/gdm/batch.js
js/ui/iconGrid.js
js/ui/overviewControls.js
js/ui/switcherPopup.js
js/ui/workspace.js

index bd84c9230c38834f48b90b8b83d176295c12c687..3671210e04837d15e136d8ce0bcbeba6af23e645 100644 (file)
@@ -124,7 +124,7 @@ var Batch = class extends Task {
     }
 
     process() {
-        throw new Error('Not implemented');
+        throw new GObject.NotImplementedError(`process in ${this.constructor.name}`);
     }
 
     runTask() {
index 77e871028cba2a08f0fb94ea57c9cf2d6cb46e40..4d32e8bcf8fafc47707781532a95d48fe938e899 100644 (file)
@@ -79,7 +79,7 @@ class BaseIcon extends St.Bin {
     // This can be overridden by a subclass, or by the createIcon
     // parameter to _init()
     createIcon(size) {
-        throw new Error('no implementation of createIcon in ' + this);
+        throw new GObject.NotImplementedError(`createIcon in ${this.constructor.name}`);
     }
 
     setIconSize(size) {
@@ -416,7 +416,8 @@ var IconGrid = GObject.registerClass({
 
     animatePulse(animationDirection) {
         if (animationDirection != AnimationDirection.IN)
-            throw new Error("Pulse animation only implements 'in' animation direction");
+            throw new GObject.NotImplementedError("Pulse animation only implements " +
+                                                  "'in' animation direction");
 
         this._cancelAnimation();
 
index 930bbb2209b6aced5ef554f408bfc1db9ba76cdf..f10ba7306439a46e133b1d7eee368e67f31faa79 100644 (file)
@@ -122,7 +122,7 @@ var SlidingControl = class {
     }
 
     _getSlide() {
-        throw new Error('getSlide() must be overridden');
+        throw new GObject.NotImplementedError(`_getSlide in ${this.constructor.name}`);
     }
 
     _updateSlide() {
index d324a90f46dd7b381586c5f0234e50ad30dfee4c..50a926e2947e02fdf95baae4530301e09d5804bb 100644 (file)
@@ -162,7 +162,7 @@ var SwitcherPopup = GObject.registerClass({
     }
 
     _keyPressHandler(keysym, action) {
-        throw new Error('Not implemented');
+        throw new GObject.NotImplementedError(`_keyPressHandler in ${this.constructor.name}`);
     }
 
     _keyPressEvent(actor, event) {
index 175fedce939991effc4016e6607690a026512ad9..50ac141d995615df676283659f18deb55704b9de 100644 (file)
@@ -835,7 +835,7 @@ var LayoutStrategy = class {
     // (optionally) for each row in @layout.rows. This method is
     // intended to be called by subclasses.
     _computeRowSizes(layout) {
-        throw new Error('_computeRowSizes not implemented');
+        throw new GObject.NotImplementedError(`_computeRowSizes in ${this.constructor.name}`);
     }
 
     // Compute strategy-specific window slots for each window in
@@ -848,7 +848,7 @@ var LayoutStrategy = class {
     //  * gridHeight - The totial height used by the grid, unscaled, unspaced.
     //  * rows - A list of rows, which should be instantiated by _newRow.
     computeLayout(windows, layout) {
-        throw new Error('computeLayout not implemented');
+        throw new GObject.NotImplementedError(`computeLayout in ${this.constructor.name}`);
     }
 
     // Given @layout, compute the overall scale and space of the layout.